// https://www.acwing.com/problem/content/2818/

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int m, n;
    cin>>m>>n;
    vector<int> nums1(m);
    vector<int> nums2(n);

    for (int i=0; i<m; i++) {
        cin>>nums1[i];
    }

    for (int i=0; i<n; i++) {
        cin>>nums2[i];
    }

    int t1 = 0;
    int t2 = 0;
    int result = m;
    while (t1 < m && t2 < n) {
        int target = nums1[t1];
        if (nums2[t2] == target) {
            t2++;
            t1++;
            result--;
        } else {
            t2++;
        }
    }

    if (result == 0) {
        cout<<"Yes"<<endl;
    } else {
        cout<<"No"<<endl;
    }
    return 0;
}
